import { ref } from '@vue/reactivity'
/**
 * 用于dom 全屏
 * @param elstr
 * @returns
 */
export function useFullscreen(elstr: string) {
	const isFullScreen = ref(false)
	function toggle() {
		// 取消全屏
		if (isFullScreen.value) {
			document.exitFullscreen()
			isFullScreen.value = false
		} else {
			const element = document.querySelector(elstr)
			element && element.requestFullscreen()
			isFullScreen.value = true
		}
	}
	return {
		isFullScreen,
		toggle,
	}
}
